<?php
if (isset($_POST['requestShift'])) {
    requestShift($_SESSION['userName'], $_SESSION['userPassHash'], $_POST['requestShift']);
}
$shifts = displayShiftsOffered($_SESSION['userName'], $_SESSION['userPassHash']);
?>
<h3>Shift Shop</h3>
<table class="table-striped table">
    <thead>
        <tr>
            <th>Role Name</th>
            <th>Date</th>
            <th>Employee</th>
            <th>Start Time</th>
            <th>End Time</th>
            <th>Request Shift</th>
        </tr>
    </thead>
    <tbody>
        <?php
        for ($i = 1; $i < count($shifts); $i++) {
            ?>
            <tr>
                <td><?php echo($shifts[$i]['roleName']); ?></td>
                <td><?php echo($shifts[$i]['datestamp']); ?></td>
                <td><?php echo($shifts[$i]['accName']); ?></td>
                <td><?php echo($shifts[$i]['startTime']); ?></td>
                <td><?php echo($shifts[$i]['endTime']); ?></td>
                <td><form action="" method="post">
                        <input type="hidden" name="requestShift" value='<?php
                        echo(json_encode(array(
                            'roleID' => $shifts[$i]['roleID'],
                            'dateID' => $shifts[$i]['dateID'],
                            'empID' => $shifts[$i]['empID']
                        )));
                        ?>' />
                        <input type="submit" value="Request Shift" class="btn" />
                    </form></td>
            </tr>
        <?php } ?>
    </tbody>
</table>